<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="/WEB-INF/tags/functions.tld" %>
<%@ taglib prefix="t" uri="/WEB-INF/tags/tags.tld" %>
<link rel="stylesheet" href="/css/table.css" type="text/css" media="all" />
<link rel="stylesheet" href="/css/paging.css" type="text/css" media="all" />
<link rel="stylesheet" href="/css/message.css" type="text/css" media="all" />
<script type="text/javascript" src="/js/functions.js"></script>
<script type="text/javascript" src="/js/notify.js"></script>

<h2 style="margin-left: 2%;">Danh sách học phần</h2>
<hr size="1" />

<c:if test="${msg != null}">
	<div class="notify">
		<c:out value="${msg}" />
	</div>
	<c:remove var="msg" scope="session"/>
</c:if>
<c:if test="${subjects == null or empty subjects}">
	<b>Không có học phần nào</b>
</c:if>
<c:if test="${subjects != null and !empty subjects}">
	<form action="/admin/deleteSubjects.html?p=${pageInfo.currentPage}" method="post">
		<table>
			<thead>
				<tr>
					<td class="th" style="width: 1em;"><input type="checkbox" name="checkAll" id="checkAll" /></td>
					<th class="th">STT</th>
					<th class="th">Mã học phần</th>	
					<th class="th">Tên học phần</th>
					<th class="th">Cập nhật</th>
					<th class="th">Xóa</th>
				</tr>	
			</thead>
			<tbody>
			<c:forEach items="${subjects}" var="s" varStatus="status">
				<tr>
					<td class="td" style="width: 1em;"><input type="checkbox" name="checkItem" value="${f:keyToString(s.subjectKey)}" /></td>
					<td class="td"><c:out value="${(pageInfo.currentPage - 1) * pageSize + status.count}" escapeXml="true" /></td>
					<td class="td"><c:out value="${s.subjectId}" escapeXml="true" /></td>
					<td class="td"><c:out value="${s.subjectName}" escapeXml="true" /></td>
					<c:url value="/admin/updateSubject/${f:keyToString(s.subjectKey)}.html" var="updateUrl">
						<c:param name="p" value="${pageInfo.currentPage}"></c:param>
					</c:url>
					<td class="td"><a href="${updateUrl}" class="updateLink"><img src="/images/update.png" width="15" height="15" /></a></td>
					<c:url value="/admin/deleteSubject/${f:keyToString(s.subjectKey)}.html" var="deleteUrl">
						<c:param name="p" value="${pageInfo.currentPage}"></c:param>
					</c:url>
					<td class="td"><a href="${deleteUrl}" class="deleteLink"><img src="/images/delete.png" width="15" height="15" /></a></td>
				</tr>
			</c:forEach>
			</tbody>
			<tfoot>
				<tr>
					<td colspan="6">
						<div class="pages">
							<t:paging pageInfo="${pageInfo}" link="/admin/listSubjects.html"/>
						</div>
						<input type="submit" value="Xóa" id="deleteGroup" disabled="disabled" style="margin-top: 1em; width: 4em" />
					</td>
				</tr>
			</tfoot>
		</table>
	</form>
</c:if>